package org.javaboy.session_share;

import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @Value(value = "${server.port}")
    Integer port;

    @GetMapping("/get")
    public String get(HttpSession session) {
        return "hello,port:" + port + ">>>" + session.getAttribute("name");
    }

    @GetMapping("/set")
    public String set(HttpSession session) {
        session.setAttribute("name", "javaboy");
        return "set:" + port;
    }
}
